﻿using System;
using WindowsPhoneEssentials.Controls;
using WindowsPhoneEssentials.Threading;

namespace SampleApplication.Controls
{
    public partial class LoadingPivotContent : ISendLoadStatus
    {
        private LoadStatus loadStatus;

        public LoadingPivotContent()
        {
            InitializeComponent();  
        }

        public LoadStatus LoadStatus
        {
            get { return loadStatus; }
            set
            {
                loadStatus = value;
                var handler = LoadStatusChanged;
                if (handler != null) handler(this, EventArgs.Empty);
            }
        }

        public event EventHandler LoadStatusChanged;

        private void UserControlLoaded(object sender, System.Windows.RoutedEventArgs e)
        {
            DelayedDispatcher.BeginInvoke(TimeSpan.FromSeconds(3), ()=>LoadStatus = LoadStatus.Loaded);
        }
    }
}
